# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=weevely
pkgver=928.3d62e88
pkgrel=1
groups=('blackarch' 'blackarch-webapp' 'blackarch-backdoor')
pkgdesc='Weaponized web shell.'
arch=('any')
url='http://epinna.github.io/Weevely/'
license=('GPL3')
depends=('python' 'python-yaml' 'python-prettytable' 'python-mako'
         'python-dateutil' 'python-pysocks' 'python-pyopenssl')
makedepends=('git')
source=("$pkgname::git+https://github.com/epinna/weevely3.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md CHANGELOG.md \
    requirements.txt
  install -Dm 644 "$pkgname.1" "$pkgdir/usr/share/man/man1/$pkgname.1"
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md CHANGELOG.md requirements.txt LICENSE "$pkgname.1"

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/$pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

